const BaseRoutes = require("./baseRoutes");
const SystemController = require("../controllers/systemController");

const systemRoutes = new BaseRoutes("/system", SystemController);

/**
 * @swagger
 * /system/login:
 *   post:
 *     tags:
 *       - System
 *     summary: 用户登录
 *     description: 用户登录接口
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             type: object
 *             properties:
 *               username:
 *                 type: string
 *               password:
 *                 type: string
 *     responses:
 *       200:
 *         description: 登录成功
 */
systemRoutes.router.post("/login", SystemController.login);
/**
 * @swagger
 * /system/encodePwd:
 *   post:
 *     tags:
 *       - System
 *     summary: 密码加密测试
 *     description: 模拟前端加密逻辑，返回加密后的密码（仅用于测试）
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             type: object
 *             properties:
 *               password:
 *                 type: string
 *     responses:
 *       200:
 *         description: 加密成功
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 code:
 *                   type: number
 *                 message:
 *                   type: string
 *                 success:
 *                   type: boolean
 *                 data:
 *                   type: object
 *                   properties:
 *                     encodedPwd:
 *                       type: string
 */
systemRoutes.router.post("/encodePwd", SystemController.encodePwd);
/**
 * @swagger
 * /system/updatePwd:
 *   post:
 *     tags:
 *       - System
 *     summary: 更新密码
 *     description: 更新用户密码接口
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             type: object
 *             properties:
 *               oldPassword:
 *                 type: string
 *               newPassword:
 *                 type: string
 *     responses:
 *       200:
 *         description: 密码更新成功
 */
systemRoutes.router.post("/updatePwd", SystemController.updatePwd);

/**
 * @swagger
 * /system/register:
 *   post:
 *     tags:
 *       - System
 *     summary: 用户注册
 *     description: 用户注册接口
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             type: object
 *             properties:
 *               username:
 *                 type: string
 *               password:
 *                 type: string
 *               name:
 *                 type: string
 *     responses:
 *       200:
 *         description: 注册成功
 */
systemRoutes.router.post("/register", SystemController.register);
// 暂未实现
/**
 * @swagger
 * /system/checkusername:
 *   get:
 *     tags:
 *       - System
 *     summary: 检查用户名
 *     description: 检查用户名是否已存在
 *     parameters:
 *       - in: query
 *         name: username
 *         required: true
 *         schema:
 *           type: string
 *     responses:
 *       200:
 *         description: 用户名可用
 */
systemRoutes.router.get("/checkusername", SystemController.checkUsername);
/**
 * @swagger
 * /system/departments:
 *   get:
 *     tags:
 *       - System
 *     summary: 获取部门列表
 *     description: 获取所有部门信息
 *     responses:
 *       200:
 *         description: 部门列表
 */
systemRoutes.router.get("/departments", SystemController.getDepartments);

systemRoutes.registerRoutes(); // 添加默认路由：page list ids :id

module.exports = systemRoutes.router;
